#include <iostream>

using namespace std;
class Animal
{
public:
	virtual void eat()  //虚函数
	{
		cout<<"动物吃"<<endl;
	}
};

class Dog:public Animal
{
public:
	void eat()
	{
		cout<<"狗吃骨头"<<endl;
	} 
};

class Tugou:public Dog
{
public:
	 void eat()
	{
		cout<<"土狗吃火腿肠"<<endl;
	}	
};




//C++允许 爷爷的指针或者爷爷的引用指向孙子类对象 */
void animalEat(Animal &animal) //希望具有通用性
{
	animal.eat();
}
int main()
{
	Tugou dog;
	Animal &p=dog;
	animalEat(p);
}
